package net.simflow.swf.analyzer.bggraph.opt;

import net.simflow.swf.analyzer.bgnetwork.data.BGNode;

import org.apache.commons.collections15.Transformer;

public class BGNodeToLabelTransformer implements Transformer<BGNode, String> {

	private static final int STYLE_BLANK = 0;
	private static final int STYLE_SHORT_NAME = 1;
	private static final int STYLE_NAME = 2;

	private int style;

	public static BGNodeToLabelTransformer makeInstanceBlank() {
		return new BGNodeToLabelTransformer(STYLE_BLANK);
	}

	public static BGNodeToLabelTransformer makeInstanceShortName() {
		return new BGNodeToLabelTransformer(STYLE_SHORT_NAME);
	}

	public static BGNodeToLabelTransformer makeInstanceName() {
		return new BGNodeToLabelTransformer(STYLE_NAME);
	}

	private BGNodeToLabelTransformer(int style) {
		this.style = style;
	}

	@Override
	public String transform(BGNode node) {
		switch (style) {
		case STYLE_BLANK:
			return "";
		case STYLE_SHORT_NAME:
			return node.getShortInfo();
		case STYLE_NAME:
			return node.getFullInfo();
		}
		return "";
	}
}
